﻿package com.ufenlei.LTS{
	
	 import flash.display.Sprite;
	 import flash.text.TextField;
	 import flash.events.Event;

	public class TestingItemView extends Sprite{
		private var _ti:TestingItem;
		private var _titleField:TextField;
		private var _og:TestingRadioGroup;
		public function TestingItemView(ti:TestingItem){
			_ti = ti;
			_titleField = tivtitle;
			_titleField.text = _ti.id + ". "+_ti.question;
			initOptionGroup();
		};
		private function initOptionGroup():void{
			_og = new TestingRadioGroup();
			for each( var op in _ti.optionList){
				_og.addRadio(op.desc , op.key);
				_og.addEventListener(Input.CHANGE, onChange);
			}
			this.addChild(_og);
			_og.y = 25;
			_og.x = 8;
			
		}
		private function onChange(evt:Event):void{
			_ti.setAnswer(evt.target.answer);
			trace("answerChanged to", _ti.answer);
		}
	 }
}